package com.common.domain;

import com.common.hbase.constant.PutConstant;
import com.common.hbase.domain.*;
import com.common.hbase.liaison.HbaseInterface;
import com.common.hbase.liaison.ParseInterface;

import java.util.ArrayList;
import java.util.List;

public class BehaviorBase extends ParseInterface<Behavior> implements HbaseInterface {



    private Behavior behavior;
    public BehaviorBase(Behavior behavior) {
        this.behavior = behavior;
    }

    @Override
    public CreateDomain getCreateTable() {
        return new CreateDomain(PutConstant.BEHAVIOR_RECORD_TABLE,"info");
    }

    @Override
    public List<PutDomain> getPutDomains() {
        List<PutDomain> putDomains = new ArrayList<>();
        if (!behavior.getUserid().isEmpty()){
            putDomains.add(new PutDomain(PutConstant.BEHAVIOR_RECORD_TABLE,behavior.getUuid(),"info","userid",behavior.getUserid()));
        }
        if (behavior.getDate()!=null){
            putDomains.add(new PutDomain(PutConstant.BEHAVIOR_RECORD_TABLE,behavior.getUuid(),"info","date",behavior.getDate().toString()));
        }
        if (behavior.getIncident()!=null){
            putDomains.add(new PutDomain(PutConstant.BEHAVIOR_RECORD_TABLE,behavior.getUuid(),"info","incident",behavior.getIncident()));
        }
        return putDomains;
    }

    @Override
    public String getTableName() {
        return PutConstant.BEHAVIOR_RECORD_TABLE;
    }

    @Override
    public ScanDomain getScanDomain() {
        return new ScanDomain(PutConstant.BEHAVIOR_RECORD_TABLE);
    }

    @Override
    public GetDomain getGetDomain() {
        return new GetDomain(PutConstant.BEHAVIOR_RECORD_TABLE,behavior.getUuid());
    }




}
